<?

require("required/dbconnect.php");
require("required/function.php");

if (isset($_POST['btnsubmit'])) {


    $content = $_POST['content'];
    $type = $_POST['type'];
    $id = $_POST['id'];
    $status=$_POST['status'];
    $title = mysql_escape_string($_POST['title']);
    $insert = mysql_query("update os_contents set content='$content', order_id='$order_id',title='$title',status='$status' where id=$id") or die(mysql_error());

    header("Location:content_edit.php?type=$type&msg=1&id=$id");
} else {


    require("required/header.php");

    checkAccess("allow_content_management", 1);
    ?>
    <script src="required/js/jquery-1.4.2.js"></script>
    <script src="required/js/common_javascript.js"></script>
    <?
    if (empty($_GET['id'])) {
        die("Illegal Action!!");
    }

    $id = $_GET['id'];



    $get_content = mysql_query("select * from os_contents where id='$id'") or die(mysql_error());

    if (mysql_num_rows($get_content) == 0) {
        die("Illegal Action!!");
    }
    $a = mysql_fetch_array($get_content, MYSQL_ASSOC);
    if (empty($_GET['msg'])) {
        $msg = "";
    } else {
        $msg = "<div class='dw_success'>Data updated!</div>";
        echo "<script>displayMsg('divMsg')</script>";
    }
    ?>

    <table width="100%"  cellpadding="0" cellspacing="5" height="300">

        <td width="84%" align="left" valign="top">

            <form action="<?= $_SERVER['PHP_SELF'] ?>" name="frm" method="post" onSubmit="return validatefrm(this)">
                <table width="100%">

                    <td colspan="2">

                        <div class="title">Edit Record </div>
                        <div id="divMsg"><?= $msg ?></div>
                    </td>


                    <tr valign="top">
                        <td width="17%">Title</td><td width="83%"><input type="text" value="<?= $a['title'] ?>" size="50" name="title" maxlength="200"></td>
                    </tr>
                     <tr valign="top">
                        <td width="17%">Publish</td><td width="83%">
                            <select name="status">
                                <?
                                    if($a['status']==1){
                                        $slt1="selected";
                                        $slt0="";
                                    }else{
                                        $slt1="";
                                        $slt0="selected";
                                    }
                                ?>
                                <option value="0" <?= $slt0 ?>>No</option>
                                <option value="1" <?= $slt1 ?>>Yes</option>
                                
                            </select>
                        </td>
                    </tr>

                    <tr valign="top">
                        <td>Content</td>
                        <td valign="top">
                        </td>
                    </tr>
                    <tr valign="top">
                        <td colspan="2">
    <? include_once("./fckeditor/fckeditor.php") ?>
    <?php
    $oFCKeditor = new FCKeditor('content');
    $oFCKeditor->ToolbarSet = 'DeswinBasic';
    $oFCKeditor->Height = 500;
    $oFCKeditor->BasePath = './fckeditor/';
    $oFCKeditor->Value = $a["content"];
    $oFCKeditor->Create();
    ?>


                        </td>
                    </tr>
                    <input type="hidden" value="<?= $a['content_type'] ?>" name="type">
                    <input type="hidden" value="<?= $id ?>" name="id">
                    <tr>
                        <td colspan="2">
                            <input type="submit" value="Submit" name="btnsubmit" class="button">


                        </td>
                    </tr>
                </table>
            </form>
        </td>

    </table>
<? }require("required/footer.php"); ?>